package com.guigu.basedservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.basedservice.entity.BaseCarCategory;
import com.guigu.basedservice.entity.BaseCarFactory;
import com.guigu.basedservice.mapper.BaseCarCategoryMapper;
import com.guigu.basedservice.mapper.BaseCarFactoryMapper;
import com.guigu.basedservice.service.BaseCarCategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guigu.basedservice.vo.BaseCarCategoryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 车系 服务实现类
 * </p>
 *
 * @author Heyuhang
 * @since 2024-09-12
 */
@Service
public class BaseCarCategoryServiceImpl extends ServiceImpl<BaseCarCategoryMapper, BaseCarCategory> implements BaseCarCategoryService {

    @Autowired(required = false)
    private BaseCarCategoryMapper baseCarCategoryMapper;

    @Override
    public PageInfo<BaseCarCategory> show(BaseCarCategoryVo vo, Integer currentPage, Integer pageSize) {
        QueryWrapper<BaseCarCategory> queryWrapper=new QueryWrapper<>();
        if (vo!=null) {
            if (vo.getName() != null && vo.getName() != "") {
                queryWrapper.eq("name", vo.getName());
            }
            if (vo.getBrandUuid() != null && vo.getBrandUuid() != "") {
                queryWrapper.eq("brand_uuid", vo.getBrandUuid());
            }
            if (vo.getFactoryUuid() != null && vo.getFactoryUuid() != "") {
                queryWrapper.eq("factory_uuid", vo.getFactoryUuid());
            }
        }
        PageHelper.startPage(currentPage,pageSize);
        List<BaseCarCategory> list=baseCarCategoryMapper.selectList(queryWrapper);
        PageInfo<BaseCarCategory> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }
}
